package com.java.panel; import java.awt.Color; import java.awt.Font; import java.awt.Image; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextArea; import com.java.util.MyDbUtil; /**新增备忘信息的面板 * @author Mr.xiao * */ public class AddPanel extends JFrame{ public MainPanel mp=null; JLabel jl_title=new JLabel("标题"); JTextArea jta_title=new JTextArea(); JLabel jl_content=new JLabel("内容"); JTextArea jta_content=new JTextArea(); JLabel jl_time=new JLabel("日期"); JTextArea jta_time=new JTextArea(); JButton jb_sure=new JButton("确定"); JButton jb_cancel=new JButton("取消"); Image icon=Toolkit.getDefaultToolkit().getImage("icon.png"); public AddPanel(MainPanel mp){ setIconImage(icon); this.mp=mp; setTitle("添加备忘事件"); setVisible(true); getContentPane().setBackground(new Color(29,177,213)); setLayout(null); setBounds(400, 100, 600, 500); setLayout(null); setResizable(false); //setDefaultCloseOperation(EXIT_ON_CLOSE); jta_content.setBackground(new Color(199,237,204)); jta_time.setBackground(new Color(199,237,204)); jta_title.setBackground(new Color(199,237,204)); getContentPane().add(jl_title); jl_title.setBounds(20, 20, 40, 30); getContentPane().add(jta_title); jta_title.setBounds(70,20,500,70); jta_title.setFont(new Font("Dialog",1,15)); jta_title.setLineWrap(true); getContentPane().add(jl_content); jl_content.setBounds(20, 100, 40, 30); getContentPane().add(jta_content); jta_content.setBounds(70,100,500,200); jta_content.setFont(new Font("Dialog",1,15)); jta_content.setLineWrap(true); getContentPane().add(jl_time); jl_time.setBounds(20, 310, 40, 30); getContentPane().add(jta_time); jta_time.setBounds(70,310,500,50); jta_time.setFont(new Font("Dialog",1,15)); jta_time.setLineWrap(true); getContentPane().add(jb_sure); jb_sure.setBounds(100, 400, 100, 40); getContentPane().add(jb_cancel); jb_cancel.setBounds(370, 400, 100, 40); jb_sure.addActionListener(new AddListener(mp, this)); jb_cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); } } class AddListener implements ActionListener{ MainPanel mp=null; AddPanel ap=null; public AddListener(MainPanel mp,AddPanel ap) { this.mp=mp; this.ap=ap; } @Override public void actionPerformed(ActionEvent e) { String title=ap.jta_title.getText(); String content=ap.jta_content.getText(); String time=ap.jta_time.getText(); if(title.length()<1||content.length()<1||time.length()<1){ JOptionPane.showMessageDialog(null, "请将信息填写完整"); } else{ new MyDbUtil().addThing(-1,title, content, time); ap.dispose(); mp.things.removeAllElements(); mp.things.addAll(new MyDbUtil().getAllThings()); mp.jtable.updateUI(); //JOptionPane.showMessageDialog(null, "添加成功"); } } }
最近下载更多
李朝磊 LV18
2023年11月18日
weilaizhisheng LV21
2023年9月28日
ezra77934 LV2
2023年9月15日
alexcheung LV3
2023年7月10日
微信网友_6292282163859456 LV4
2023年1月5日
计算机暴龙战士 LV19
2022年12月6日
a318888331 LV13
2022年10月31日
alonely23 LV1
2022年10月6日
zhendong LV7
2022年9月26日
xiao小果 LV12
2022年6月22日
最近浏览更多
3334004690 LV3
3月6日
shiaomon
2023年12月14日
暂无贡献等级
Anzhui LV2
2023年12月10日
李朝磊 LV18
2023年11月18日
tianshi LV7
2023年10月19日
weilaizhisheng LV21
2023年9月28日
ezra77934 LV2
2023年9月15日
alexcheung LV3
2023年7月10日
ds9009 LV7
2023年6月26日
1145304128 LV12
2023年5月20日